class Solution:
    def maxProduct(self, nums) -> int:
        if len(nums) == 1:
            return nums[0]
        maxP = nums[0]
        minCon = nums[0]
        maxCon = nums[0]

        for i in range(1, len(nums)):
            minTmp = minCon * nums[i]
            maxTmp = maxCon * nums[i]
            minCon = min(minTmp, nums[i], maxTmp)
            maxCon = max(minTmp, nums[i], maxTmp)
            maxP = max(maxCon, maxP)
        return maxP


if __name__ == '__main__':
    so = Solution()
    s = [-2,0,-1]
    r = so.maxProduct(s)
    print(r)
